package org.example.finaspringboot.service.serviceiml;


import org.example.finaspringboot.entity.Blog;
import org.example.finaspringboot.mapper.BlogMapper;
import org.example.finaspringboot.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogServiceIml implements BlogService {
    @Autowired
    BlogMapper blogMapper;
    @Override
    public List<Blog> findAll() {
        return blogMapper.selectAll();
    }

    @Override
    public int count() {
        return blogMapper.countBlogs();
    }

    @Override
    public List<Blog> findByPage(int page, int size) {
        int offset = (page - 1) * size;
        return blogMapper.findBlogsByPage(offset, size);
    }
}
